# 定义元组
dimensions = (200, 50)
print(dimensions[0])


# 元组中的元素无法被修改
# dimensions[0] = 250

# 遍历元组中的元素
for dimension in dimensions:
    print(dimension)

# 元组常用API示例
# 1. 索引访问
print("第一个元素:", dimensions[0])
print("最后一个元素:", dimensions[-1])

# 2. 切片操作
print("前两个元素:", dimensions[:2])

# 3. 元组连接
dimensions2 = (300, 100)
combined = dimensions + dimensions2
print("连接后的元组:", combined)

# 4. 元组重复
repeated = dimensions * 3
print("重复3次的元组:", repeated)

# 5. 内置函数使用
print("元组长度:", len(dimensions))
print("元素50出现的次数:", dimensions.count(50))
print("元素50的索引位置:", dimensions.index(50))